import { _decorator, Canvas, Component, Node, ResolutionPolicy, Size, view ,screen, js} from 'cc';
import { registerBUrlByCfg, UIManager } from './core/modules/ui/UIManager';
import { ResManager } from './core/modules/res/ResManager';
import { LoginCtr } from './GamePlay/modules/Match3/LoginCtr';
import { Match3UI } from './GamePlay/modules/Match3/Match3UI';
import { PrefabCfg } from './auto/PrefabCfg';
const { ccclass, property } = _decorator;

//新增全局变量申明
declare global {
    const gtr : GCtr;
}

@ccclass('GCtr')
export class GCtr extends Component {

    readonly loginCtr =  new LoginCtr();
    readonly res = new ResManager();
    readonly ui = new UIManager();
    
    async init(param:{
        canvas2d:Canvas,
        releaseBoostFun:Function
    }){

        // 全局变量设置
        (globalThis as any)["gtr"] = this;

        //提前注册预制信息
        registerBUrlByCfg(PrefabCfg);
        //界面管理器二阶段构造
        gtr.ui.init(param.canvas2d);
        //登录模块二阶段构造
        this.loginCtr.init();

        //显示登录界面
        this.loginCtr.showLogin(async () => {

            // await gtr.res.loadBundleAsync("Match3BN");
            await gtr.ui.open(Match3UI);
            param.releaseBoostFun();

        })


    }

}


